from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
    def get(self):
        user = users.get_current_user()
        if user:
            greeting = "You're logged on as <b>%s</b> (<a href=\"%s\">sign out</a>)." % (user.nickname(), users.create_logout_url("/"))
            self.response.out.write("<html><body>%s<br>" % greeting)
            #Manage user profile
            self.response.out.write("<br><a href=\"/user\">Manage users profiles</a>")
            #Manage location
            self.response.out.write("<br><a href=\"/location\">Manage locations</a>")
            #Manage route
            self.response.out.write("<br><a href=\"/guide\">Create a city tour</a>")
            self.response.out.write("</body></html>")
          
        else:
          greeting = "Please, <a href=\"%s\">sing in or register</a>." % users.create_login_url("/")
          self.response.out.write("<html><body>%s</body></html>" % greeting)


application = webapp.WSGIApplication([('/', MainPage)], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
